﻿@using EcBlog.Properties
@using Telerik.Web.Mvc.UI
@{
    ViewBag.Title = "Manage Settings";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}

@section head{ 
    @Html.Partial("_Head")
    <script type="text/javascript">
        function onError(e) {
            e.preventDefault();
            alert(e.XMLHttpRequest.getResponseHeader("message"));
        } 
        
        function onDataBoundSiteSettingGrid() {
            replaceDeleteConfirmation(this, '@ModelLocalization.DeleteConfirmation', '@ModelLocalization.SiteSetting');
        } 
    </script>
}

@(Html.Telerik().Grid<EcBlog.Models.SiteSetting>()
    .Name("SiteSettingGrid") 
    .Columns(columns => {
        columns.Command(commands => commands.Edit().ButtonType(GridButtonType.Image)).Width(80);
            columns.Bound(c => c.SettingKey); 
            columns.Bound(c => c.SettingValue); 
        }) 
        .DataBinding(dataBinding => 
            dataBinding.Ajax()
                .Select("List", "Setting", new { area = "Admin" })
                .Update("Update", "Setting", new { area = "Admin" }))
        .DataKeys(keys => keys.Add(c => c.SettingKey).RouteKey("SettingKey"))
        .Pageable(p => p.PageSize(100))
        .Scrollable()
        .KeyboardNavigation()
        .Filterable()
        .Groupable()
        .Sortable(sorting => sorting.SortMode(GridSortMode.MultipleColumn))
        .Reorderable(c => c.Columns(true))
        .Resizable(c => c.Columns(true))
        .Editable(c => c.Mode(GridEditMode.InLine))
        .EnableCustomBinding(true)
        .ColumnContextMenu()
        .ClientEvents(events =>
            events
                .OnError("onError")
                .OnDataBound("onDataBoundSiteSettingGrid"))
)

